#include "stdafx.h"
#include "Path.h"
//#include "MyCommon.h"



PointList Path::CreateRandomPath(int NumWaypoints,MyReal MinX,
								 MyReal MinY,MyReal MaxX, MyReal MaxY)
{
	m_wayPoints.clear();

	MyReal midX = (MaxX+MinX)/2.0;
	MyReal midZ = (MaxY+MinY)/2.0;

	MyReal smaller = MyCommon::Math::Min(midX, midZ);
	MyReal spacing = MyCommon::Math::TWO_PI/(double)NumWaypoints;

	for (int i=0; i<NumWaypoints; i++)
	{
		MyReal radialDist = MyCommon::Math::RangeRandom(smaller*0.2f,smaller);
		MyVec3 temp(radialDist,0,0);
		/*Matrix4 mat(Matrix4::IDENTITY);
		mat.Rotate(Radian(radialDist));
		mat.transformAffine(temp);*/
		MyCommon::Quaternion q(MyCommon::Radian(i*spacing),MyVec3(0,1,0));
		q.RotateVector3(temp);
		temp.x += midX;
		temp.z += midZ;
		m_wayPoints.push_back(temp);
	}
	m_curWayPoint = m_wayPoints.begin();
	return m_wayPoints;
}